package com.sunfield.windpower.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sunfield.baseframe.base.MyBaseAdapter;
import com.sunfield.windpower.R;
import com.sunfield.windpower.bean.NewsInfo;

import org.androidannotations.annotations.EBean;

/**
 * Created by wxl on 2017/2/8.
 */
@EBean
public class FileGridAdapter extends MyBaseAdapter<NewsInfo.File> {
    public FileGridAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_file, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        NewsInfo.File data = getItem(position);
        viewHolder.tv_file_name.setText(data.getName());

        return convertView;
    }

    public static class ViewHolder {
        View rootView;
        public TextView tv_file_name;
        public TextView tv_file_size;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tv_file_name = (TextView) rootView.findViewById(R.id.tv_file_name);
            this.tv_file_size = (TextView) rootView.findViewById(R.id.tv_file_size);

            tv_file_name.setEllipsize(TextUtils.TruncateAt.MIDDLE);
        }

    }
}
